//
//  QHHCPManager.h
//  MUGH
//
//  Created by 李志良的mac mini on 2020/3/27.
//  Copyright © 2020 MUGH. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "QHHCPInternalPreferences.h"
#import "QHHCPManifestDiff.h"
#import "QHHCPDownLoader.h"
#import "QHUpdateAlert.h"
#import "QHHCPUpdateProgress.h"
NS_ASSUME_NONNULL_BEGIN
typedef void (^QHHCPManagerCompleteBlock)(BOOL isReload);

typedef enum {

    QHSelectedUpdate  = 1, //选择更新/提示更新

    QHAutoUpdate,         // 静默更新

    QHInviteUpdate,       // 邀请更新，测试用，输入邀请码更新
} QHUpdateType;

@interface QHHCPManager :  CDVPlugin

@property(nonatomic,retain) QHHCPFileManager * hcpFileManager;

@property(nonatomic,retain) NSString * wwwContentFolderName;

 @property(nonatomic,retain) NSString * webserviceVersionName;

@property(nonatomic,retain) QHHCPManifestDiff * manifestDiff;

//
@property(nonatomic,copy) QHHCPManagerCompleteBlock updateCompleteBlock;

//提示框
@property(nonatomic,retain) QHHCPUpdateProgress * updateAlertView;

//邀请更新的邀请码
@property(nonatomic,retain) NSArray * InviteCodes;
@property(nonatomic,retain) NSString * InviteCodeWyhs;

@property(nonatomic,retain) NSString * updateOpraType;
//打开方式：open：进入程序打开 systemSetting：系统设置打开
@property(nonatomic,retain) NSString * openMode;
//记录有几个www需要更新，目前总数是2
@property(nonatomic,assign) NSInteger updateCount;
//文件数
@property(nonatomic,assign) NSInteger updateFilesCount;

@property(nonatomic,assign) NSInteger autoUpdateFilesCount;

//记录保存更新信息
@property(nonatomic,retain) NSString * updateAlertMessage;
//静默更新信息数组
@property(nonatomic,retain) NSMutableArray * silentUpdateInfoArray;
//静默更新差别文件数组
@property(nonatomic,retain) NSMutableArray * silentManifestDiffArray;
//提示更新信息数组
@property(nonatomic,retain) NSMutableArray * alertUpdateInfoArray;
//提示更新差别文件数组
@property(nonatomic,retain) NSMutableArray * alertManifestDiffArray;
//判断提示框是否弹出
@property(nonatomic,assign) BOOL isUpdateAlertPresenting;
//更新总进度
@property(nonatomic,assign) float totalUpdateProgress;

@property(nonatomic,assign) int updateIndex;
//静默更新下载任务索引
@property(nonatomic,assign) int silentUpdateIndex;
//www包名
@property(nonatomic,retain) NSArray * wwwFolderArray;
@property(nonatomic,assign) int bundleNumber;
+ (QHHCPManager *)sharedManager;

// 更新完成后是否需要 刷新 H5
@property (nonatomic,assign) BOOL isNeedReload;


//检查与从服务获取更新信息
//-(void)checkAndDownloadVersionMessageWithName:(NSString*)wwwFolderName updateSuccess:(QHHCPManagerCompleteBlock)success;
-(void)copyBundleToLocal;
-(void)checkAllBundleUpdateWithMode:(NSString *)openMode andCompleteBlock:(QHHCPManagerCompleteBlock)completeBlock;
//邀请码更新
//⚠️⚠️⚠️inviteCodes，bundleNames  集合内容顺序必须一致
-(void)updateWithIviteCodes:(NSArray*)inviteCodes bundleNames:(NSArray*)bundleNames andCompleteBlock:(QHHCPManagerCompleteBlock)completeBlock;

@end

NS_ASSUME_NONNULL_END

